package io.renren.modules.avanotes.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.avanotes.dao.Supermemo2SpecialReviewDao;
import io.renren.modules.avanotes.entity.Supermemo2SpecialReviewEntity;
import io.renren.modules.avanotes.service.Supermemo2SpecialReviewService;
import org.springframework.stereotype.Service;

import java.util.Map;


//@Service("supermemo2SpecialReviewService")//默认只有一个实现，那就不写名称了直接使用默认的名称！
@Service
public class Supermemo2SpecialReviewServiceImpl extends ServiceImpl<Supermemo2SpecialReviewDao, Supermemo2SpecialReviewEntity> implements Supermemo2SpecialReviewService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<Supermemo2SpecialReviewEntity> page = this.page(
                new Query<Supermemo2SpecialReviewEntity>().getPage(params),
                new QueryWrapper<Supermemo2SpecialReviewEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Supermemo2SpecialReviewEntity selectLatestOneByScheduleIdAndSpecialIdAndUserId(Long scheduleId, Integer specialId, Long userId) {
        QueryWrapper<Supermemo2SpecialReviewEntity> queryWrapper = new QueryWrapper<Supermemo2SpecialReviewEntity>().eq(Supermemo2SpecialReviewEntity.CN_SCHEDULE_ID, scheduleId).eq(Supermemo2SpecialReviewEntity.CN_SPECIAL_ID, specialId)
                .eq(Supermemo2SpecialReviewEntity.CN_CREATE_USER_ID, userId);
        return this.baseMapper.selectOne(queryWrapper);
    }

}